﻿using System.Configuration;
using System.ServiceModel;
using Autofac;

namespace Hippo.Agent.Lib
{
    public class AgentContainerBuilder : ContainerBuilder
    {
        public AgentContainerBuilder()
        {
            this.Register(c => new AgentConfigurationProfile(ConfigurationManager.AppSettings));

            /* ConsoleClient */
            this.Register(c => new InstanceContext(new ControlServerCallback()));
            this.RegisterType<EndpointDiscovery>().As<IEndpointDiscovery>();

            this.Register(c => new ConsoleClient(c.Resolve<InstanceContext>(), c.Resolve<IEndpointDiscovery>()))
                .InstancePerLifetimeScope();
        }
    }
}
